<?php $this->load->view('header'); ?>

    <!-- Page Content -->
    <div id="search-project">
        <?php echo $this->load->view('sideBlocks/searchBlock') ?>
    </div>
    <div class="wrap-content wrap-project">
        <div class="container">
            <div class="row find-job">
                <div class="col-lg-12 col-sm-12 col-md-12 col-xs-12 no-padding find-job-title">
                    <div class="f30-m"><?php echo $this->lang->line('Job Search Result');?></div>
                    <div class="f18-m green-2"><?php echo $total_project . ' ' .$this->lang->line('were found based on your criteria');?></div>
                </div>

                <div class="col-lg-3 col-sm-3 col-md-3 col-xs-3 menu-categories-find col-left">
                    <p class="f18-m green-2"><?php echo $this->lang->line('All Categories');?></p>
                    <ul>
                        <?php
                        if(count($listParentCategories) > 0){
                            foreach($listParentCategories as $item) {
                                if($params != null && array_key_exists ('g', $params)){
                                    $tmp = $params;
                                    $tmp['g'] = $item['id'];
                                    if($item['id'] == $params['g']){
                                        $liClass = "class='selected'";
                                        $link_group = "javascript:void();";
                                    }else{
                                        $liClass = '';
                                        $link_group = site_url('joblist/viewAlljoblistsUpdate/'.build_url($tmp));
                                    }
                                }elseif($params != null && !array_key_exists ('c', $params)){
                                    $liClass = '';
                                    $link_group = site_url('joblist/viewAlljoblistsUpdate/'.build_url($params));
                                }else{
                                    $liClass = '';
                                    $link_group = site_url('joblist/viewAlljoblistsUpdate/g/'.$item['id']);
                                }
                                ?>

                                <li <?php echo (isset($liClass))?$liClass:'';?>><a href="<?php echo $link_group;?>"><?php echo $item['name']?></a>
                                    <ul>
                                        <?php
                                        if( (isset($item['child']) == TRUE ) &&    count($item['child']) > 0) {
                                            foreach ($item['child'] as $item_child) {
                                                if($params != null && array_key_exists ('c', $params)){
                                                    $tmp = $params;
                                                    $tmp['c'] = $item_child['id'];
                                                    if($item_child['id'] == $params['c']){
                                                        $liClassChild = 'class="selected"';
                                                        $link_cat = "javascript:void();";
                                                    }else{
                                                        $liClassChild = '';
                                                        $link_cat = site_url('joblist/viewAlljoblistsUpdate/'.build_url($tmp));
                                                    }
                                                }elseif($params != null && !array_key_exists ('g', $params)){
                                                    $liClassChild = '';
                                                    $link_cat = site_url('joblist/viewAlljoblistsUpdate/'.build_url($params));
                                                }else{
                                                    $liClassChild = '';
                                                    $link_cat = site_url('joblist/viewAlljoblistsUpdate/c/'.$item_child['id']);
                                                }
                                                ?>
                                                <li <?php echo (isset($liClassChild))?$liClassChild:'';?>><a href="<?php echo $link_cat?>"><?php echo $item_child['name']?></a></li>
                                            <?php
                                            }
                                        }
                                        ?>
                                    </ul>
                                </li>
                            <?php   }
                        }
                        ?>

                    </ul>
                    <div class="block-left">
                        <p class="f18-m green-2"><?php echo $this->lang->line('Country');?> </p>
                        <form action="" method="POST">
                            <select class="select-sort selectpicker country" name="country">
                                <?php
                                if($countries->num_rows() > 0) {
                                    foreach ($countries->result() as $item) {
                                        if(isset($params) && $params['ct'] == $item->id){
                                            echo "<option selected value='".$item->id."'>".$item->country_name."</option>";
                                        }else{
                                            echo "<option value='".$item->id."'>".$item->country_name."</option>";
                                        }
                                    }
                                }
                                ?>
                            </select>
                        </form>
                    </div>
                    <ul class="block-left">
                        <p class="block-left-title"><?php echo $this->lang->line('Any budget');?> </p>
                        <li class="f18-m green-2" style="background: none;list-style: initial;margin-left: 20px;padding-left: 0px;margin-bottom: 15px;"><?php echo $this->lang->line('Specific Budget');?> </li>
                        <?php
                            $budget_min = '';
                            $budget_max = '';
                            if(isset($params['bg'])){
                                $budget = explode('-', $params['bg']);
                                $budget_min = $budget[0];
                                $budget_max = $budget[1];
                            }
                        ?>
                        <form action="" method="POST" id="frm-bubget">
                            <span>$</span> <input type="text" class="form-control budget" placeholder="Min" name="budget_min" value="<?php echo $budget_min;?>">
                            <span>to $</span> <input type="text" class="form-control budget" placeholder="Max" name="budget_max" value="<?php echo $budget_max;?>">
                            <div class="col-lg-12 col-sm-12 no-padding" style="text-align: right; margin-top:10px;">
                                <input type="submit" class="btn btn-default btn-bubget" value="OK">
                            </div>
                        </form>
                    </ul>
                    <ul class="block-left">
                        <p class="block-left-title"><?php echo $this->lang->line('DATE POSTED');?> </p>
                            <?php
                            $link_date = '';
                            if($params != null && array_key_exists ('dp', $params)){
                                $tmp = $params;
                                unset($tmp['dp']);
                                $link_date = build_url($tmp);
                            }elseif($params != null){
                                $link_date = build_url($params);
                            }
                            ?>
                            <li>
                                <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/'.$link_date)?>"><?php echo $this->lang->line('Any timeframe');?></a>
                            <li <?php echo (isset($params['dp']) && $params['dp'] == 1)?'class="selected"':''?>>
                                <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/dp/1/'.$link_date)?>"><?php echo $this->lang->line('Last 24 Hourse');?></a>
                            </li>
                            <li <?php echo (isset($params['dp']) && $params['dp'] == 3)?'class="selected"':''?>>
                                <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/dp/3/'.$link_date)?>"><?php echo $this->lang->line('Last 3 Days');?></a>
                            </li>
                            <li <?php echo (isset($params['dp']) && $params['dp'] == 7)?'class="selected"':''?>>
                                <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/dp/7/'.$link_date)?>"><?php echo $this->lang->line('Last 7 Days');?></a>
                            </li>
                            <li <?php echo (isset($params['dp']) && $params['dp'] == 14)?'class="selected"':''?>>
                                <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/dp/14/'.$link_date)?>"><?php echo $this->lang->line('Last 14 Days');?></a>
                            </li>
                            <li <?php echo (isset($params['dp']) && $params['dp'] == 30)?'class="selected"':''?>>
                                <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/dp/30/'.$link_date)?>"><?php echo $this->lang->line('Last 30 Days');?></a>
                            </li>
                    </ul>
                    <ul class="block-left">
                        <p class="block-left-title"><?php echo $this->lang->line('JOB STATUS');?> </p>
                        <?php
                        $link_status = '';
                        if($params != null && array_key_exists ('st', $params)){
                            $tmp = $params;
                            unset($tmp['st']);
                            $link_status = build_url($tmp);
                        }elseif($params != null){
                            $link_status = build_url($params);
                        }
                        ?>
                        <li class="f18-m green-2">
                            <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/'.$link_status)?>"><?php echo $this->lang->line('Any');?></a>
                        </li>
                        <li <?php echo (isset($params['st']) && $params['st'] == 0)?'class="selected"':''?>>
                            <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/st/0/'.$link_status)?>"><?php echo $this->lang->line('Open jobs');?></a>
                        </li>
                        <li <?php echo (isset($params['st']) && $params['st'] == 1)?'class="selected"':''?>>
                            <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/st/1/'.$link_status)?>"><?php echo $this->lang->line('Jobs in progress');?></a>
                        </li>
                        <li <?php echo (isset($params['st']) && $params['st'] == 2)?'class="selected"':''?>>
                            <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/st/2/'.$link_status)?>"><?php echo $this->lang->line('Completed jobs');?></a>
                        </li>
                        <li <?php echo (isset($params['st']) && $params['st'] == 3)?'class="selected"':''?>>
                            <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/st/3/'.$link_status)?>"><?php echo $this->lang->line('Cancelled jobs');?></a>
                        </li>
                    </ul>

                </div>


                <div class="col-lg-9 col-sm-9 col-md-9 col-xs-9">

                        <?php
                        if($joblistprojects->num_rows() > 0){
                            foreach ($joblistprojects->result() as $project) {
                        ?>
                        <div class="row-find-job ol-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 padding-right">
                                <a href="<?php echo site_url('project/view/'.$project->id)?>">
                                    <?php
                                    if(is_attachment_exists($project->attachment_avatar)){
                                        $link_image = prfile_url($project->attachment_avatar);
                                    }else{
                                        $link_image =  prfile_url('avt_project_default.png');
                                    }
                                    ?>
                                    <img src="<?php echo $link_image; ?>" class="img-responsive" alt="<?php echo $project->project_name?>"/>
                                </a>
                            </div>
                            <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 no-padding">
                                <div class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding project-name">
                                    <a href="<?php echo site_url('project/view/'.$project->id)?>">
                                    <?php echo $project->project_name?>
                                   
                                    </a><span class="glyphicon glyphicon-heart <?php echo (isset($project_wishlist) && $project_wishlist != null && in_array($project->id, $project_wishlist))?'active-wishlist':'project-wishlist';?>" data-id="<?php echo $project->id?>" data-url="<?php echo current_url();?>"></span>
                                </div>
                                <div class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding project-info">
                                    <span><?php echo $this->lang->line('Est.budget') . ': $' . $project->budget_min . ' - $' . $project->budget_max?></span>
                                    <span>
                                        <?php echo $this->lang->line('Posted')?>:
                                        <?php
                                        if(date("d/m/y") == date("d/m/y",$project->created)){
                                            echo $this->lang->line('Ending today');
                                        }else{
                                            echo date("d/m/y", $project->created);
                                        }
                                        ?>
                                    </span>
                                    <span>
                                        <?php echo $this->lang->line('Ends')?>:
                                        <?php
                                        if(date("d/m/y") == date("d/m/y",$project->enddate)){
                                            echo $this->lang->line('Ending today');
                                        }else{
                                            echo date("d/m/y", $project->enddate);
                                        }
                                        ?>
                                    </span>
                                    <span><?php echo getNumBid($project->id) .' '. $this->lang->line('Applications')?></span>
                                </div>

                                <div class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding">
                                    <?php echo cutStringDes($project->description, 200)?>
                                </div>
                                <span class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding">
                                    <a href="#">more</a>
                                </span>
                                <div class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding">
                                    <span class="col-md-3 col-lg-1 col-xs-3 col-sm-3 no-padding">Skills: </span>
                                    <div class="col-md-9 col-lg-11 col-xs-9 col-sm-9 no-padding list-skill">
                                        <ul>
                                            <?php echo getCategoryLinks2($project->project_categories);?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php
                            }
                        }else{
                            echo '<div class="row-find-job ol-lg-12 col-md-12 col-sm-12 col-xs-12">';
                            echo $this->lang->line('No Results');
                            echo '</div>';
                        }
                        ?>

                    <div class="job-pagination text-center col-lg-12 col-md-12 col-sm-12">
                        <?php if(isset($pagination)) echo $pagination;?>
                    </div>
                </div> <!-- info-find-freelancer -->

            </div> <!-- end row content -->
        </div>
    </div> <!-- wrap-content -->

<?php $this->load->view('footer'); ?>